//
// Created by fl on 23-9-5.
//

#include "get_time.h"

uint64_t currentTimeMs() {
    struct timeval tv{};
    gettimeofday(&tv,nullptr);    //该函数在sys/time.h头文件中
    return tv.tv_sec * 1000 + tv.tv_usec / 1000;
}

uint64_t elapsedTimeMs(uint64_t t) {
    return currentTimeMs() - t;
}

// 单位微秒
uint64_t currentTimeUs() {
    struct timeval tv{};
    gettimeofday(&tv,nullptr);    //该函数在sys/time.h头文件中
    return tv.tv_sec * 1e6 + tv.tv_usec;
}

// 单位微秒
uint64_t elapsedTimeUs(uint64_t t) {
    return currentTimeUs() - t;
}